<template>
  <div>
    <div class="main-wrap">
      <div class="count-wrap flex">
        <div class="flex count-content">
          <div class="count-li">
            <img
              class="tag"
              src="../../../assets/img/img_number.png"
            >
            <p class="title">
              领星总订单数
            </p>
            <p class="num">
              {{StaticData.lxtotal_count}} <span class="lastday">({{StaticData.lxlastorder}}至今)</span>
            </p>
            <div class="analysis">
              <span class="dialog-footer">
                昨日
              </span>
              <span class="desc">

                <span class="yesterday">
              {{StaticData.lxyesterday_count}}
                </span>
              </span>
              <div class="process por">

              <el-progress 
              :text-inside="true" 
              :stroke-width="26" 
              :percentage="StaticData.lxtodayandyester?Number(StaticData.lxyesterday_count*100/StaticData.lxtodayandyester).toFixed(2):0" />
            </div>

            </div>
            <div class="analysis">
              <span class="dialog-footer">
                今日
              </span>
              <span class="desc">

                <span class="yesterday">{{StaticData.lxtoday_count}}</span>
              </span>
              <div class="process por">
                <el-progress
      :text-inside="true"
      :stroke-width="24"
      :percentage="StaticData.lxtodayandyester?Number(StaticData.lxtoday_count*100/StaticData.lxtodayandyester).toFixed(2):0"
      status="success"
    />
              </div>
            </div>
          </div>
          <div class="count-li">
            <img
              class="tag"
              src="../../../assets/img/img_number.png"
            >
            <p class="title">
              速猫总订单数
            </p>
            <p class="num">
              {{StaticData.smtotal_count}} <span class="lastday">({{StaticData.smlastorder}}至今)</span>
            </p>
            <div class="analysis">
              <span class="dialog-footer">
                昨日
              </span>
              <span class="desc">

                <span class="yesterday">
              {{StaticData.smyesterday_count}}
                </span>
              </span>
              <div class="process por">
                <el-progress 
              :text-inside="true" 
              :stroke-width="26" 
              :percentage="StaticData.smtodayandyester?Number(StaticData.smyesterday_count*100/StaticData.smtodayandyester).toFixed(2):0" />
              </div>
            </div>
            <div class="analysis">
              <span class="dialog-footer">
                今日
              </span>
              <span class="desc">

                <span class="yesterday">
                  {{StaticData.smltoday_count}}</span>
              </span>
              <div class="process por">
                <el-progress 
              :text-inside="true" 
              :stroke-width="26" 
              :percentage="StaticData.smtodayandyester?Number(StaticData.smltoday_count*100/StaticData.smtodayandyester).toFixed(2):0" />
              </div>
            </div>
          </div>
        </div>
        <ul class="countUl flex w_50">
          <li
            class="cfff por"
            data-tip="历史累计订单总发货数，包含退货订单。"
          >
            <p class="tit f20">
              总发货数
              <i class="icon icon_exampleTag mgl10 mgt_5 ver_a_m cursor_p" />
            </p>
            <p class="num">{{StaticData.totalsend_count}}</p>
            <p class="analysis f18">
              领星:
              <span class="yesterday mgr20">{{StaticData.lxtotalSend}}</span>
              速猫:
              <span class="today">{{StaticData.smtotalSend}}</span>
            </p>
          </li>
          <li
            class="cfff por"
  
          >
            <p class="tit f20">
              总订单数
              <i class="icon icon_exampleTag mgl10 mgt_5 ver_a_m cursor_p" />
            </p>
            <p class="num ">{{StaticData.total_count}}</p>
            <p class="analysis f18">
              领星
              <span class="yesterday mgr20">{{StaticData.lxtotal_count}}</span>
              速猫
              <span class="today">{{StaticData.smtotal_count}}</span>
            </p>
          </li>
          <li
            class="cfff por"
            data-tip="待发货订单数。"
          >
            <p class="tit f20">
              待发货订单数
              <i class="icon icon_exampleTag mgl10 mgt_5 ver_a_m cursor_p" />
            </p>
            <p class="num">{{StaticData.totalpresend_count}}</p>
            <p class="analysis f18">
              领星
              <span class="yesterday mgr20" style="cursor: pointer;" @click="sendorder(1)">{{StaticData.lxtotalpreSend}}</span>
              速猫
              <span class="today" style="cursor: pointer;" @click="sendorder(2)">{{StaticData.smtotalpreSend}}</span>
            </p>
          </li>
          <li
            class="cfff por"
            data-tip="历史累计迟发订单数。"
          >
            <p class="tit f20">
              迟发订单数
              <i class="icon icon_exampleTag mgl10 mgt_5 ver_a_m cursor_p" />
            </p>
            <p class="num">{{StaticData.totaloverdue_count}}</p>
            <p class="analysis f18">
              领星
              <span class="yesterday mgr20" style="cursor: pointer;" @click="lateorder(1)">{{StaticData.lxoverdue}}</span>
              速猫
              <span class="today" style="cursor: pointer;" @click="lateorder(2)">{{StaticData.smoverdue}}</span>
            </p>
          </li>
        </ul>

      </div>
      <div class="chartWrap">
        <Chart />
      </div>
    </div>
  </div>

</template>

<script setup>
import { QuestionFilled } from '@element-plus/icons-vue'
import Chart from './component/chart.vue'
import {getdataboard,getstattrends } from '@/api/data'
import { ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useRouterStore } from '@/pinia/modules/router'
import {showLoading,closeLoading } from '@/utils/common'
const router = useRouter()
const route = useRouter()
const StaticData = ref({});
const TrendData = ref([]);
defineOptions({
  name: 'DatasBoard'
})
const getDataInfo = async () => {
  showLoading()
  getdataboard().then((res) => {
    closeLoading()
    if (res.errcode == 0) {
      StaticData.value = res.content
    }
  });
}
const getTrendDataInfo = async () => {
  const res = await getstattrends()
  if (res.code === 0) {
    TrendData.value = res.data

  }
}
const lateorder=(type)=>{
  let params = {
      is_overdue:1
  }
  let name = '';
  if(type==1){
    name = 'LxOrder'
  }
  if(type==2){
    name = 'SumoolOrder'
  }
  router.push({ name: name, query:params })

}
const sendorder=(type)=>{
  let params = {
      status:5
  }
  let name = '';
  if(type==1){
    name = 'LxOrder'
    params = {
      status:5
  }
  }
  if(type==2){
    name = 'SumoolOrder'
    params = {
      status:3
  }
  }
  router.push({ name: name, query:params })

}
getDataInfo();
// getTrendDataInfo();
</script>

<style lang="scss">
.lastday{
  font-size: 14px;
  margin-left: 20px;
  color: #3e3e3e;
  font-weight: 400;
}
.main-wrap{
    width: 100%;
    background-color: #f7f7f7;
}

.count-content {
    width: 50%;
}
.count-li {
    position: relative;
    width: 48%;
    margin-right: 2%;
    height: auto;
    box-sizing: border-box;
    padding: 20px;
    border-radius: 20px;
    background-color: #FFFFFF;

    .logo {
        width: 40px;
    }

    .title {
        font-size: 24px;
    }

    .tag {
        position: absolute;
        width: 30px;
        height: 30px;
        top: 10px;
        right: 10px;
    }

    .num {
        margin: 20px 0px;
        font-size: 22px;
        font-weight: 600
    }

    .analysis {
        font-size: 16px;
        margin-top: 26px;
    }

    .process{
        position: relative;
        width: 100%;
        height: 16px;
        border-radius: 13px;
        margin-top: 5px;
        background-color: #f3f3f3;;

        .yesterline{
            display: block;
            position: absolute;
            left: 0;
            top: 0;
            height: 26px;
            border-radius: 13px;
            background-color: #2878ff;
        }
        .todayline{
            display: block;
            position: absolute;
            left: 0;
            top: 0;
            height: 26px;
            border-radius: 13px;
            background-color: #23b93c;
        }
    }
}

.countUl {
    width: 50%;
    margin-right: -2%;
    flex-wrap: wrap;

    li{
        width: 48%;
        margin-right: 2%;
        height: 0;
        padding: 46px 30px 34% 40px;
        box-sizing: border-box;
        margin-bottom: 20px;
        border-radius: 12px;
        background-size: 100% 100%;
        padding-top: 10px;
        padding-left: 30px;
        padding-bottom: 20%;
        color: #FFFFFF;

        .num {
            font-size: 22px;
            margin:10px 0px;
            font-weight: 800
        }

        .tit {
            font-size: 18px;
        }

        .icon_exampleTag {
            width: 20px;
            height: 20px;
            cursor: pointer;
            background-image: url('https://saas.jitangcn.com/images/icon/icon_exampleTag.png');
        }
        .mgr20{
          margin-right: 20px;
        }
        .analysis {
            font-size: 16px;
        }

        &:nth-child(1) {
            background-image: url('https://saas.jitangcn.com/images/li/img_li.png');
        }

        &:nth-child(2) {
            margin-right: 0;
            background-image: url('https://saas.jitangcn.com/images/li/img_li2.png');
        }

        &:nth-child(3) {
            margin-bottom: 0;
            background-image: url('https://saas.jitangcn.com/images/li/img_li2.png');
        }

        &:nth-child(4) {
            margin-bottom: 0;
            background-image: url('https://saas.jitangcn.com/images/li/img_li4.png');
        }
    }
}

.chartWrap {
    margin-top: 20px;
    background-color: #fff;
    border-radius: 20px;

    .title-wrap {
        justify-content: space-between;
        font-size: 20px;
        padding: 40px 20px;
    }

    .chart {
        width: 990px;
        height: 100px;
        margin: 0 auto;
    }
}
</style>
